﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using static YunRuiFarm.Models.DatabaseModels;

namespace YunRuiFarm.Models
{
    public class ResultModel<T>
    {
        public bool IsSuccess { get; set; }
        public string Message { get; set; }
        public T Data { get; set; }
    }
    public class IndexMessagetModel<T>
    {
        public bool IsSuccess { get; set; }
        public string Name { get; set; }
        public T Data { get; set; }
    }
    public class UserInfoMessagetModel<T>
    {
        public bool IsSuccess { get; set; }
        public string Name { get; set; }
        public int Sex { get; set; }
        public string Contacts { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
    }
    public class AdoptMessagetModel<T>
    {
        public T Data1 { get; set; }
        public T Data2 { get; set; }
        public int Code { get; set; }
        public string Kind1 { get; set; }
        public int Number1 { get; set; }
        public string Kind2 { get; set; }
        public int Number2 { get; set; }
    }
    public class AdoptGoatMessagetModel<T>
    {
        public T data1 { get; set; }
        public T data2 { get; set; }
        public string Kind { get; set; }
        public string Introduce { get; set; }
        public int Number { get; set; }
    }
    public class GoatAppointmentMessagetModel<T>
    {
        public bool IsSuccess { get; set; }
        public string Name { get; set; }
        public string Contacts { get; set; }
    }
    public class CommonGetMessagetModel<T>
    {
        public int code { get; set; }
        public string msg { get; set; }
        public int count { get; set; }
        public T data { get; set; }
    }
    public class GoatOrderMessagetModel<T>
    {
        public int code { get; set; }
        public string msg { get; set; }
        public int count { get; set; }
        public T data { get; set; }
    }
    public class ReturnUploadModel<T>
    {
        public int code { get; set; }
        public string msg { get; set; }
        public T data { get; set; }
    }
    public class GoatOrderListModel
    {
        public long PersonID { get; set; }
        public string UserName { get; set; }
        public string OrderId { get; set; }
        public string Name { get; set; }
        public string Contacts { get; set; }
        public string Kind { get; set; }
        public int Number { get; set; }
        public string Order { get; set; }
        public string Createtime { get; set; }
        public string Updatetime { get; set; }
        
    }
    public class RestaurantOrderListModel
    {
        public long Id { get; set; }
        public string OrderId { get; set; }
        public long PersonID { get; set; }
        public string Name { get; set; }
        public string Contacts { get; set; }
        public string Date { get; set; }
        public int Number { get; set; }
        public bool Private { get; set; }
        public string Result { get; set; }
        public string Activity { get; set; }
        public string RastRestaurant { get; set; }
        public string Remarks { get; set; }
    }
    public class userfeedbackListModel
    {
        public long Id { get; set; }
        public long PersonId { get; set; }
        public string Message { get; set; }
        public string Answer { get; set; }
        public string Result { get; set; }
        public string Createtime { get; set; }
    }
    public class GoatOrderDetailtModel<T>
    {
        public int code { get; set; }
        public string msg { get; set; }
        public int count { get; set; }
        public T data { get; set; }
    }
    public class GoatOrderDetailtListModel
    {
        public long Id { get; set; }
        public string OrderId { get; set; }
        public string GoatId { get; set; }
        public string Time { get; set; }
        public string Report { get; set; }
    }
    public class AgriculturalMessagetModel<T>
    {
        public int code { get; set; }
        public string msg { get; set; }
        public int count { get; set; }
        public T data { get; set; }
        public T carouselfigure { get; set; }
    }
    public class AgriculturalOrderListModel
    {
        public long Id { get; set; }
        public string OrderId { get; set; }
        public string Agricultural { get; set; }
        public string Name { get; set; }
        public string Contacts { get; set; }
        public int Number { get; set; }
        public double Price { get; set; }
        public string Result { get; set; }
        public string Time { get; set; }
        public string Remarks { get; set; }
        public string Createtime { get; set; }
        public int Style { get; set; }
        public string Total { get; set; }
    }
    public class AdministratorsPictureListModel
    {
        public long Id { get; set; }
        public string Place { get; set; }
        public string Detail { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
        public string PicUrl { get; set; }
        public string Createtime { get; set; }
        public string Updatetime { get; set; }
    }
    public class AdministratorsProductListModel
    {
        public long Id { get; set; }
        public string Kind { get; set; }
        public double Price { get; set; }
        public string Brief { get; set; }
        public string Introduce { get; set; }
        public string Total { get; set; }
        public int Time { get; set; }
        public string Picture { get; set; }
        public int Sort { get; set; }
        
    }
    public class ResultHelper
    {
        public static ResultModel<string> GetSuccessModel(string Message)
        {
            return new ResultModel<string>
            {
                IsSuccess = true,
                Data = "",
                Message = Message
            };
        }
        public static ResultModel<string> GetErrorModel(string Message)
        {
            return new ResultModel<string>
            {
                IsSuccess = false,
                Data = "",
                Message = Message
            };
        }
        public static ResultModel<string> RegisterErrorModel(string Message)
        {
            return new ResultModel<string>
            {
                IsSuccess = false,
                Message = Message
            };
        }
        public static IndexMessagetModel<string> RegisterSuccessModel(string Name)
        {
            return new IndexMessagetModel<string>
            {
                IsSuccess = true,
                Name = Name
            };
        }
        public static ResultModel<string> GetIndexMessageModel(string Message)
        {
            return new ResultModel<string>
            {
                IsSuccess = true,
                Data = "",
                Message = Message
            };
        }
        public static UserInfoMessagetModel<string> GetUserInfoModel(string name,int sex,string contacts,string username,string password)
        {
            return new UserInfoMessagetModel<string>
            {
                IsSuccess = true,
                Name=name,
                Sex=sex,
                Contacts=contacts,
                Username = username,
                Password=password
            };
        }
        public static ResultModel<string> GetIndexMessageErrorModel(string Message)
        {
            return new ResultModel<string>
            {
                IsSuccess = false,
                Message = Message
            };
        }
        public static ResultModel<string> GetLoginMessageSuccessModel(string Name)
        {
            return new ResultModel<string>
            {
                IsSuccess = true,
                Message = Name
            };
        }
        public static ResultModel<string> GetLoginMessageErrorModel(string Name)
        {
            return new ResultModel<string>
            {
                IsSuccess = false,
                Message = Name
            };
        }
        public static AdoptMessagetModel<object> GetAdoptMessageModel(object CarouselFigure,object Introduction, int code, string Kind1, int Number1,string Kind2, int Number2)
        {
            return new AdoptMessagetModel<object>
            {
                Data1= CarouselFigure,
                Data2 = Introduction,
                Code = code,
                Kind1 = Kind1,
                Number1 = Number1,
                Kind2=Kind2,
                Number2=Number2,
            };
        }
        public static AdoptGoatMessagetModel<object> GetAdoptGoatMessageModel(object list1, object list2, string Kind, int Number, string Introduce)
        {
            return new AdoptGoatMessagetModel<object>
            {
                data1 = list1,
                data2=list2,
                Kind = Kind,
                Number = Number,
                Introduce= Introduce,
            };
        }
        public static GoatAppointmentMessagetModel<string> GetGoatAppointmentSuccessModel(string Name, string Contacts)
        {
            return new GoatAppointmentMessagetModel<string>
            {
                IsSuccess = true,
                Name = Name,
                Contacts = Contacts
            };
        }
        public static GoatAppointmentMessagetModel<string> GetGoatAppointmentErrorModel()
        {
            return new GoatAppointmentMessagetModel<string>
            {
                IsSuccess = false
            };
        }
        
        public static GoatOrderMessagetModel<object> GetGoatOrderMessageModel(object list, int count)
        {
            var dictionary = (List<goat_adopt>)list;
            List<GoatOrderListModel> data = new List<GoatOrderListModel>();
            //将list中的日期修改为string格式
            for (int i=0;i< dictionary.Count; i++)
            {
                GoatOrderListModel message = new GoatOrderListModel();
                message.PersonID = dictionary[i].PersonID;
                message.UserName = user_info.FindById(dictionary[i].PersonID).Name;
                message.OrderId= dictionary[i].OrderId;
                message.Name = dictionary[i].Name;
                message.Contacts = dictionary[i].Contacts;
                message.Kind = dictionary[i].Kind;
                message.Number = dictionary[i].Number;
                message.Order = dictionary[i].Result;
                message.Createtime = dictionary[i].Createtime.ToString("yyyy-MM-dd");
                data.Add(message);
            }
            return new GoatOrderMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
        public static GoatOrderMessagetModel<object> GetUserRestaurantOrderMessageModel(object list, int count)
        {
            var dictionary = (List<cater_order>)list;
            List<RestaurantOrderListModel> data = new List<RestaurantOrderListModel>();
            //将list中的日期修改为string格式
            for (int i = 0; i < dictionary.Count; i++)
            {
                RestaurantOrderListModel message = new RestaurantOrderListModel();
                var DetailList = cater_detail.FindBySql("select * from cater_detail where OrderId='" + dictionary[i].OrderId+"'");
                message.Id = dictionary[i].Id;
                message.OrderId = dictionary[i].OrderId;
                message.Name = dictionary[i].Name;
                message.Contacts = dictionary[i].Contacts;
                message.Date = dictionary[i].Date+ DetailList[0].Time;
                message.Number = dictionary[i].Number;
                message.Result = dictionary[i].Result;
                message.Activity = DetailList[0].Activity;
                message.RastRestaurant = DetailList[0].Restaurant;
                message.Remarks = DetailList[0].Remarks;
                data.Add(message);
            }
            return new GoatOrderMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
        public static GoatOrderMessagetModel<object> GetUserFeedbackMessageModel(object list, int count)
        {
            var dictionary = (List<user_feedback>)list;
            List<userfeedbackListModel> data = new List<userfeedbackListModel>();
            //将list中的日期修改为string格式
            for (int i = 0; i < dictionary.Count; i++)
            {
                userfeedbackListModel message = new userfeedbackListModel();
                message.Id = dictionary[i].Id;
                message.Message = dictionary[i].Message;
                message.Answer = dictionary[i].Answer;
                message.Createtime = dictionary[i].Createtime.ToString("yyyy-MM-dd");
                message.Result = dictionary[i].Result;
                data.Add(message);
            }
            return new GoatOrderMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
        public static GoatOrderDetailtModel<object> GoatOrderDetailSuccessrModel(object list, int count)
        {
            var dictionary = (List<user_adoptinfo>)list;
            List<GoatOrderDetailtListModel> data = new List<GoatOrderDetailtListModel>();
            //将list中的日期修改为string格式
            for (int i = 0; i < dictionary.Count; i++)
            {
                GoatOrderDetailtListModel message = new GoatOrderDetailtListModel();
                message.Id = dictionary[i].Id;
                message.OrderId = dictionary[i].OrderId;
                message.GoatId = dictionary[i].GoatId;
                message.Report = dictionary[i].Report;
                message.Time = dictionary[i].Time.ToString();
                data.Add(message);
            }
            return new GoatOrderDetailtModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
        public static GoatOrderDetailtModel<object> GoatOrderDetailErrorModel(string msg)
        {
            return new GoatOrderDetailtModel<object>
            {
                code = 1,
                msg = msg,
                count = 0,
                data = ""
            };
        }
        public static AgriculturalMessagetModel<object> AgriculturalMessageModel(object list,object CarouselFigure, int count)
        {
            return new AgriculturalMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = list,
                carouselfigure = CarouselFigure
            };
        }
        public static GoatOrderMessagetModel<object> GetAgriculturalOrderMessageModel(object list, int count)
        {
            var dictionary = (List<DatabaseModels.product_order>)list;
            List<AgriculturalOrderListModel> data = new List<AgriculturalOrderListModel>();
            for (int i = 0; i < dictionary.Count; i++)
            {
                AgriculturalOrderListModel message = new AgriculturalOrderListModel();
                message.Id= dictionary[i].Id;
                message.OrderId = dictionary[i].OrderId;
                message.Agricultural = product_info.FindById(dictionary[i].AgriculturalID).Kind;
                message.Total = product_info.FindById(dictionary[i].AgriculturalID).Total;
                message.Name = dictionary[i].Name;
                message.Contacts = dictionary[i].Contacts;
                message.Number = dictionary[i].Number;
                message.Price = dictionary[i].Price;
                message.Result = dictionary[i].Result;
                message.Remarks = dictionary[i].Remarks;
                message.Time = dictionary[i].Time.ToString();
                message.Createtime = dictionary[i].Createtime.ToString();
                message.Style = dictionary[i].Style;
                data.Add(message);
            }
            return new GoatOrderMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
        public static CommonGetMessagetModel<object> GetIndexMessageModel(object list, int count)
        {
            return new CommonGetMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = list
            };
        }
        public static ResultModel<object> AgriculturalAdoptSuccessModel(object list)
        {
            return new ResultModel<object>
            {
                IsSuccess = true,
                Data = list,
                Message = ""
            };
        }
        public static ResultModel<List<cater_order>> GoatRestaurantMessageSuccessModel(List<cater_order> Data)
        {
            return new ResultModel<List<cater_order>>
            {
                IsSuccess = true,
                Data = Data,
                Message = ""
            };
        }
        public static GoatOrderMessagetModel<object> GetAdministratorsPictureMessageModel(object list, int count)
        {
            var dictionary = (List<web_info>)list;
            List<AdministratorsPictureListModel> data = new List<AdministratorsPictureListModel>();
            //将list中的日期修改为string格式
            for (int i = 0; i < dictionary.Count; i++)
            {
                AdministratorsPictureListModel message = new AdministratorsPictureListModel();
                message.Id = dictionary[i].Id;
                message.Place = dictionary[i].Place;
                message.Detail = dictionary[i].Detail;
                message.PicUrl = dictionary[i].PicUrl;
                message.Createtime = dictionary[i].Createtime.ToString("yyyy-MM-dd");
                message.Updatetime = dictionary[i].Updatetime.ToString("yyyy-MM-dd");
                data.Add(message);
            }
            return new GoatOrderMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
        public static GoatOrderMessagetModel<object> GetAdministratorsAgriculturalMessageModel(object list, int count)
        {
            var dictionary = (List<product_info>)list;
            List<AdministratorsProductListModel> data = new List<AdministratorsProductListModel>();
            //将list中的日期修改为string格式
            for (int i = 0; i < dictionary.Count; i++)
            {
                AdministratorsProductListModel message = new AdministratorsProductListModel();
                message.Id = dictionary[i].Id;
                message.Kind = dictionary[i].Kind;
                message.Price = dictionary[i].Price;
                message.Brief = dictionary[i].Brief;
                message.Introduce = dictionary[i].Introduce;
                message.Total = dictionary[i].Total;
                message.Time = dictionary[i].Time;
                message.Picture = dictionary[i].Picture;
                message.Sort = dictionary[i].Sort;
                data.Add(message);
            }
            return new GoatOrderMessagetModel<object>
            {
                code = 0,
                msg = "",
                count = count,
                data = data
            };
        }
    }
    public class ResultHelper<T>
    {
        public static ResultModel<T> GetLoginModel(T model)
        {
            return new ResultModel<T>()
            {
                IsSuccess = true,
                Message = "",
                Data = model
            };
        }
    }

}